package com.hmall.search.controller;

import com.hmall.common.dto.Item;
import com.hmall.common.dto.PageDTO;
import com.hmall.search.pojo.ItemDoc;
import com.hmall.search.pojo.RequestParams;
import com.hmall.search.service.ISearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Map;

/**
 * @author Mr_Su
 * @version v1.0
 * @date 2022/6/20 23:52
 * @desciption
 */
@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    private ISearchService iSearchService;

    @PostMapping("/list")
    public PageDTO<ItemDoc> search(@RequestBody RequestParams params) throws IOException {
        return iSearchService.search(params);
    }

    @PostMapping("/filters")
    public Map filters(@RequestBody RequestParams params) throws IOException {
        return iSearchService.filters(params);
    }
}
